<?php

/**
 * Controller nay se handle cac request lien quan den check out, 
 * gio hang, luu order, xem lich su order...
 * 
 * @author Tuyet
 * @package Controller
 * @subpackage N/A
 * @category Order
 */
class Checkout extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->helper(array('form', 'url'));
        $this->load->model('m_categories');
        $this->load->model('m_provinces');
        $this->load->model('m_order');
        

        //Lay du lieu category menu cho layout dung chung.
        $data['categories'] = $this->m_categories->getcategoryparent();
        $data['allcategory'] = $this->m_categories->getallcategories();
        $data['allprovinces']=  $this->m_provinces->allprovinces();
        $data['alldistricts']= $this->m_provinces->alldistricts();
        $data['menu'] = array('categories' => $data['categories'], 'allcategory' => $data['allcategory']);
        $this->load->vars($data);
    }

    //Trang dat hang buoc 1.
    public function index() {
        $data['show'] = 'frontend/checkout/account';
        $this->load->view('frontend/layout', $data);
        //  $this->load->view('frontend/checkout/account');
    }

    //Trang chi tiet gio hang.
    public function cart() {
        $data['show'] = 'frontend/cart/detail';
        $this->load->view('frontend/layout', $data);
    }

    //Trang wishlist.
    public function wishlist() {
        $data['show'] = 'frontend/checkout/wishlist';
        $this->load->view('frontend/layout', $data);
    }

    //Trang lish su mua hang.
    public function order_history() {
        $data['show'] = 'frontend/checkout/order_history';
        $this->load->view('frontend/layout', $data);
    }

    public function order() {
//        $mahd='';
//        $sum='';
//        $email='';
//        $success_url='';
//        $url_cancel='';
//        =>url;
//        redirect($uri);
           $str = date("Y-m-d H:i:s");
//           $order= array(
//               "province_id" => $pro_id,
//               "ordel_total" =>$this->input->post('ordel_total'), 
//               
//               "order_shipping",
//               "order_discount",
//               "order_date"=>$str,
//               "f_name"=>  $this->input->post('firstname'),
//               "l_name"=>  $this->input->post('lastname'),
//               "email"=> $this->input->post('email'),
//               "address"=> $this->input->post('address'),
//               "phone"=> $this->input->post('phone'),
//               "mobil_phone"=> $this->input->post('mobil_phone'),
//               "df_name"=>  $this->input->post('dfirstname'),
//               "dl_name"=>  $this->input->post('dlastname'),
//               "d_email"=> $this->input->post('demail'),
//               "d_address"=> $this->input->post('daddress'),
//               "d_phone"=> $this->input->post('dphone'),
//               "d_mobil_phone"=> $this->input->post('dmobil_phone')
//               
//               
//               );
           $total= $this->input->post('ordel_total');
           echo $total;
    }
    public function order_detail(){
        
    }

    public function myaccount() {
        $data['show'] = 'frontend/checkout/account';
        
        $this->load->view('frontend/layout', $data);
    }
    

}
